<template>
	<view>
		<uNavbar title=""></uNavbar>
		<view class="search flex_dq">
			<image src="../../static/icon/i_ss.png" mode=""></image>
			<input type="text" placeholder-style="font-size:14px" v-model.trim="searchs" @confirm="isConfirm" placeholder="请输入品牌名称" />
			<text class="tits" @click="initList">搜索</text>
		</view>
		<view class="brandDetail_box flex_Z">
			<text>品牌DAO</text>
			<view class="brandDetail flex_dq" v-for="(item,index) in brandList" :key="index" @click="goDetails(item.id)">
				<image :src="item.logo" mode="aspectFill"></image>
				<text class="f30 c0">{{item.name}}</text>
			</view>
		</view>
		<!-- 暂无数据 / 加载更多 -->
		<noDatas :xxxList="brandList" :status="status"></noDatas>
	</view>
</template>

<script>
	import {brandList} from '../../api/store.js'
	export default {
		data() {
			return {
				page: 1,
				size: 20,
				status: 'loadmore', //加载前值为loadmore，加载中为loading，没有数据为nomore
				searchs: '',
				brandList: []
			}
		},
		onLoad() {
			this.initList()
		},
		methods: {
			// 初始化
			initList() {
				let data = {
					page: this.page,
					name:this.searchs
				}
				brandList(data).then(res => {
					console.log(res)
					if(res.code == 1){
						let list = res.data.data;
						this.brandList = this.page == 1 ? list : this.brandList.concat(list);
						console.log(this.brandList);
						if (list.length < this.size) this.status = 'nomore';
					}
				})
			},
			isConfirm() {
				this.initList()
			},
			goDetails(id){
				uni.navigateTo({
					url:'/pagesMy/brandCenter/brandHomepage?id=' + id
				})
			}
		},
		// 下拉刷新
		onPullDownRefresh() {
			console.log('下拉刷新');
			let that = this;
			setTimeout(function() {
				that.page = 1,
					that.brandList = [],
					that.initList()
			}, 800);
		},
		//触底加载
		onReachBottom() {
			console.log('触底加载');
			if (this.status != 'nomore') {
				this.page = this.page + 1
				this.initList()
			}
		}
	}
</script>
<style>
	page {
		background: #211E38;
	}
</style>
<style scoped>
	.search {
		position: relative;
		width: 690rpx;
		height: 68rpx;
		background: #322D59;
		margin: 30rpx auto;
		border-radius: 40rpx;
	}

	.search>image {
		width: 40rpx;
		height: 40rpx;
		margin: 0 40rpx 0 26rpx;
	}

	.search::before {
		content: '';
		position: absolute;
		top: 18rpx;
		left: 80rpx;
		transform: translateX(-50%);
		height: 36rpx;
		width: 2rpx;
		background: #E5E5E5;
	}

	.search>input {
		color: #ffffff;
		width: 70%;
	}
	.tits{
		background: linear-gradient( 274deg, #0014FF 0%, #8020EF 50%, #FF2CDF 100%);
		border-radius: 40rpx;
		font-size: 26rpx;
		color: #ffffff;
		padding: 10rpx 20rpx;
	}
	.brandDetail_box{
		width: 690rpx;
		margin: 90rpx auto 30rpx;
	}
	.brandDetail_box>text{
		font-size: 36rpx;
		color: #ffffff;
		margin-bottom: 30rpx;
	}
	.brandDetail{
		margin-bottom: 30rpx;
	}
	.brandDetail>image{
		width: 88rpx;
		height: 88rpx;
		border-radius:50%;
		margin-right: 26rpx;
	}
	
	
	
</style>